package gmail.structure;

import java.util.ArrayList;


/**
 * Data Structure to represent a GMail Conversation Entry
 * @author siuying
 * @version 0.3.3
 */

public class GMConversationEntry implements java.io.Serializable{
    /**
     * 
     */
    private static final long serialVersionUID = -3382742840243550550L;
    private String index;
    private String id;
    private String sender;
    private String sender_email;
    private String recv;
    private String recv_email;
    private String reply_email;
    private String dt_easy;
    private String dt;
    private String subj;
    private String snippet;
    private String body;
    private ArrayList attachment;
    
    /**
     * initialize variables
     */
    public GMConversationEntry(){
        index = " ";
        id = " ";
        sender = " ";
        sender_email = " ";
        recv = " ";
        recv_email = " ";
        reply_email = " ";
        dt_easy = " ";
        dt = " ";
        subj = " ";
        snippet = " ";
        body = " ";
        attachment = new ArrayList();
    }
    
    /**
     * Append text to current message body
     * @param String body Text to append
     */
    public void appendBody(String body){
        this.body = this.body + body;
    }
    
    public void setBody(String body){
        this.body = body;
    }
    
    public String getBody(){
        return body;
    }
    public ArrayList getAttachment() {
        return attachment;
    }
    public String getDt() {
        return dt;
    }
    public String getDt_easy() {
        return dt_easy;
    }
    public String getIndex() {
        return index;
    }
    public String getId() {
        return id;
    }
    public String getRecv() {
        return recv;
    }
    public String getRecv_email() {
        return recv_email;
    }
    public String getReply_email() {
        return reply_email;
    }
    public String getSender_email() {
        return sender_email;
    }
    public String getSender() {
        return sender;
    }
    public String getSnippet() {
        return snippet;
    }
    public String getSubj() {
        return subj;
    }
    public void setSubj(String subj) {
        this.subj = subj;
    }
    public void setAttachment(ArrayList attachment) {
        this.attachment = attachment;
    }
    public void setDt(String dt) {
        this.dt = dt;
    }
    public void setDt_easy(String dt_easy) {
        this.dt_easy = dt_easy;
    }
    public void setId(String id) {
        this.id = id;
    }
    public void setIndex(String index) {
        this.index = index;
    }
    public void setRecv(String recv) {
        this.recv = recv;
    }
    public void setRecv_email(String recv_email) {
        this.recv_email = recv_email;
    }
    public void setSender(String sender) {
        this.sender = sender;
    }
    public void setReply_email(String reply_email) {
        this.reply_email = reply_email;
    }
    public void setSender_email(String sender_email) {
        this.sender_email = sender_email;
    }
    public void setSnippet(String snippet) {
        this.snippet = snippet;
    }
    public String toString(){
        StringBuffer buf = new StringBuffer();
        
        buf.append("GMConversationEntry: { index: " + index + "\n");
        buf.append("id: " + id + "\n");
        buf.append("sender: " + sender + "\n");
        buf.append("sender_email: " + sender_email + "\n");
        buf.append("recv: " + recv + "\n");
        buf.append("recv_email: " + recv_email + "\n");
        buf.append("reply_email: " + reply_email + "\n");
        buf.append("dt_easy: " + dt_easy + "\n");
        buf.append("dt: " + dt + "\n");
        buf.append("subj: " + subj + "\n");
        buf.append("snippet: " + snippet + "\n");
        buf.append("body: " + body + "\n");
        buf.append("attachment: " + attachment + "} ");
        
        return buf.toString();
    }
    
    public boolean equals(GMConversationEntry entry){
        return entry.getIndex().intern() == this.getIndex().intern() &&
        entry.getId().intern() == this.getId().intern() &&
        entry.getSender().intern() == this.getSender().intern() &&
        entry.getSender_email().intern() == this.getSender_email().intern() &&
        entry.getRecv().intern() == this.getRecv().intern() &&
        entry.getRecv_email().intern() == this.getRecv_email().intern() &&
        entry.getReply_email().intern() == this.getReply_email().intern() &&
        entry.getDt_easy().intern() == this.getDt_easy().intern() &&
        entry.getDt().intern() == this.getDt().intern() &&
        entry.getSubj().intern() == this.getSubj().intern() &&
        entry.getSnippet().intern() == this.getSnippet().intern() &&
        entry.getBody().intern() == this.getBody().intern() &&
        entry.getAttachment().equals(this.getAttachment());
    }
    
}
